<?php

namespace App\Http\Controllers\Api\v1;

use App\Models\Divination;
use App\Models\Question;
use Illuminate\Http\Request;
use App\Http\Controllers\Api\BaseController;

class DivinationController extends BaseController
{
    //
    public function index(){
        $data = Divination::with('plant','constellation','palace','before','now','future')->where('user_id',$request->uid)->where('type_id','<',4)->where('type_id','>',1)->OrderBy('created_at','desc')->paginate(10,['id','type_id','user_id','problem','planet_id','constellation_id','palace_id','before_id','now_id','future_id','created_at','updated_at']);
        return show(200,'加载成功',$data);
    }

    public function delete(Request $request){
    	$id = $request->input('id');
    	//$question = (new Question())->where(['user_id'=>$request->uid,'divination_id'=>$id,'status'=>1])->get();
        $data = Divination::where('user_id',$request->uid)->where('id',$id)->where('type_id','<',4)->where('type_id','>',1)->OrderBy('created_at','desc')->delete();
        return show(200,'删除成功',$data);
    }
}
